var values = [1,2,3,4,5];
var sum = values.reduce(function(prev, cur, index, array){
    console.log(prev,cur,index,array);
    return prev + cur;

},0);   //数组一开始加了一个初始值10,可以不设默认0

console.log(sum);  
//https://blog.csdn.net/yuanwen52/article/details/118418576